package com.example.mybaties.testone.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class Md5Util {

    /**
     * md5加密
     *
     * @param password       密码
     * @param salt           盐
     * @param hashIterations 加密次数
     *                       SimpleHash(String algorithmName, Object source, Object salt, int hashIterations)
     */
    public static String md5(String password, String salt, int hashIterations) {
        ByteSource saltByteSource = ByteSource.Util.bytes(salt);
        SimpleHash simpleHash = new SimpleHash("md5", password, saltByteSource, hashIterations);
        return simpleHash.toString();
    }

}
